﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DiveManager
{
    public partial class Rental_NewGroup : Form
    {
        protected DiveDatabaseEntities diveDatabase;
        
        public Rental_NewGroup()
        {
            InitializeComponent();

            // Init Database
            diveDatabase = new DiveDatabaseEntities();
        }

        private void Rental_NewGroup_Load(object sender, EventArgs e)
        {

        }

        private void btAdd_Click(object sender, EventArgs e)
        {
            //Artikel wird der Artikelgruppe hinzugefügt
            // Generate new Object for DB
            Rental_Group newrentalgroup = new Rental_Group();
            newrentalgroup.ID = Guid.NewGuid();
            newrentalgroup.Name = txGroupname.Text;
            newrentalgroup.Bezeichnung = txDescription.Text;
            newrentalgroup.Preis_Normal = System.Convert.ToDouble(txNormal.Text);
            newrentalgroup.Preis_Club = System.Convert.ToDouble(txClub.Text);

            // Add to DB
            diveDatabase.AddToRental_Group(newrentalgroup);
            diveDatabase.SaveChanges();

            MessageBox.Show("Gruppe erfolreich angelegt");

            txNormal.Clear();
            txClub.Clear();
            txGroupname.Clear();
            txDescription.Clear();
            
             
        }

        private void btQuit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
